package 笔试题.滴滴;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * 施展魔法
 *
 */
public class Main2 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int[] number = new int[n];
        for (int i = 0; i < n; i++) {
            number[i] = sc.nextInt();
        }

        List<Integer> index = new ArrayList<>();
        for (int i = 0; i < number.length - 1; i++) {
            if (number[i] - number[i + 1] == x) index.add(i);
        }

        if (index.size() == 0) {
            System.out.println(n);
            return;
        }
        if (index.size() == 1) {
            System.out.println(n - index.size() - 1);
            return;
        }

        //最大连续数
        int max = 0;
        int count = 0;
        for (int i = 0; i < index.size() - 1; i++) {
            if (index.get(i) + 1 == index.get(i + 1)) {
                count++;
            } else {
                max = Math.max(max, count);
                count = 0;
            }
        }

        System.out.println(n - max - 1);
    }
}
